package com.wowo.aop.perform;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

//代表切面，提供公共服务，切面类
@Component
@Aspect
public class Audience {

    //切点
    @Pointcut("execution(* com.wowo.aop.perform.*.*(..))")
    public void perf(){}
    //在表演之前
    //通知advice
    //@Before("execution(void com.wowo.aop.perform.PerformerImpl.show())")
    @Before("perf()")
    public void turnOff(){
        System.out.println("关掉手机");
    }
    @After("perf()")
    public void appload(){
        System.out.println("鼓掌");
    }
    //JoinPoint:联接点
    //环绕
    @Around("perf()")
    public Object aroundShow(ProceedingJoinPoint pjp) throws Throwable {
        //获得当前正在执行业务逻辑方法的一些信息
        //System.out.println("in around before");
        long start = System.currentTimeMillis();
        System.out.println(pjp.getSignature().toLongString()+" , "+pjp.getArgs().length+" , "+pjp.getArgs()[0]);
        Object obj = pjp.proceed();
        System.out.println(obj);
        //System.out.println("in around after");
        long end = System.currentTimeMillis();
        System.out.println("执行法的毫秒数"+(end-start));
        return (String)obj+" 你太美";
    }

}
